package com.easy.zhihu.dao;

import com.easy.zhihu.pojo.Wishes;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Packge com.easy.zhihu.dao
 * @Autor linNaibin
 * @Description
 * @Version 1.0
 * @Date 2021/3/16 16:23
 */
public interface WishesRepository extends JpaRepository<Wishes, Long> {

    @Query("select num from Wishes where word=?1 and sex=?2")
    Integer findNum(String word, int sex);

    @Modifying
    @Query("update Wishes t set t.num = t.num + 1 where t.word =?1 and t.sex=?2")
    void addNum(String word, int sex);

}
